package com.xml.actions;



import com.opensymphony.xwork2.ActionSupport;
import com.xml.services.LoginService;
import com.xml.services.LoginServiceImpl;


public class LoginAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String username;
	private String password;
	private String identity;
	private LoginService ls;
	
	public String execute() throws Exception{
		boolean flag;
		if(identity.equals("admin")){
			flag=false;
			ls = new LoginServiceImpl();
			flag = ls.checkAdmin(username, password);
			if(flag==true){
				return "admin";}
			else
				return LOGIN;
		}else if(identity.equals("reader")){
			flag=false;
			ls = new LoginServiceImpl();
			flag = ls.checkReader(username, password);
			if(flag==true){
				return "reader";}
			else
				return LOGIN;
		}else
			return "error";
	}
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getIdentity() {
		return identity;
	}
	public void setIdentity(String identity) {
		this.identity = identity;
	}

	public LoginService getLs() {
		return ls;
	}

	public void setLs(LoginService ls) {
		this.ls = ls;
	}


	

}
